layui.use(['layer', 'form', 'admin', 'laydate', 'ax','func', 'formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var func = layui.func;
    
    //绑定事件
    $(document).on('click', '#btnOpenb', function(data) {
    	var id = $("#id").val();
    	var pushId = $("#pushId").val();
        var status = $(this).attr("name");
        var title = "";
        if(status == '1'){
    		title = "你确认要设置精选吗?";
    	}else{
    		title = "你确认要取消精选吗?";
    	}
		layer.confirm(title, function() {
			var data = {
					id : id,
					pushId : pushId,
					indexShow : status
				};
			//调用ajax局部启动
			$.ajax({
				url : Feng.ctxPath + "/modular/user_dynamic/update",
				type : "POST",
				data :JSON.stringify(data),
				dataType : "json",
				contentType: "application/json;charset=UTF-8",
				async : false,
				cache : false,
				success : function(obj) {
					if (obj != null) {
						if (obj.success) {
							layer.msg("操作成功");
						} else {
							layer.msg("操作失败");
						}
					}
					 admin.putTempData('formOk', true);
	                 //关掉对话框
	                 admin.closeThisDialog();
				}
			});
			setTimeout("layer.close(layer.index);",2000);
		});
    });
    
    //绑定事件
    $(document).on('click', '#btnOpena', function(data) {
        var status = $(this).attr("name")
        var id = $("#id").val();
        var title = "";
        if(status == '1'){
    		title = "你确认要审核通过吗?";
    	}else{
    		title = "你确认要审核拒绝吗?";
    	}
		layer.confirm(title, function() {
			var data = {
					id : id,
					isAudit : status
				};
			//调用ajax局部启动
			$.ajax({
				url : Feng.ctxPath + "/modular/user_dynamic/update",
				type : "POST",
				data :JSON.stringify(data),
				dataType : "json",
				contentType: "application/json;charset=UTF-8",
				async : false,
				cache : false,
				success : function(obj) {
					if (obj != null) {
						if (obj.success) {
							layer.msg("操作成功");
						} else {
							layer.msg("操作失败");
						}
					}
					 admin.putTempData('formOk', true);
	                 //关掉对话框
	                 admin.closeThisDialog();
				}
			});
			setTimeout("layer.close(layer.index);",2000);
		});
    });
    
    $(document).on('click', '#btnRm', function(data) {
        var id = $("#id").val();
		layer.confirm('你确认要删除此条动态吗?', function() {
			//调用ajax局部启动
			$.ajax({
				url : Feng.ctxPath + "/modular/user_dynamic/delete?id="+id,
				type : "POST",
				dataType : "json",
				async : false,
				cache : false,
				success : function(obj) {
					if (obj != null) {
						if (obj.success) {
							layer.msg("操作成功");
						} else {
							layer.msg("操作失败");
						}
					}
					 admin.putTempData('formOk', true);
	                 //关掉对话框
	                 admin.closeThisDialog();
				}
			});
			setTimeout("layer.close(layer.index);",2000);
		});
    });

});
